
set more off

cd "C:\Users\myshk\OneDrive\Documents"

log using "Implicit Tax Rate Results.smcl", replace

use pva_revenue_analysis.dta
joinby ncesid year using kerafinvars.dta, unmatched(master)
tab _merge
drop _merge
joinby ncesid year using distenrollmentccd.dta, unmatched(master)
tab _merge
drop _merge
by year, sort: egen stenroll=sum(enrollmentccd)
gen invstenroll=1.5/stenroll
gen assessmentpp=assessment/enrollmentccd
gen maxtier1amt=.15*adj_seek_base
gen maxtier1pp=maxtier1amt/enrollmentccd
gen maxtier1rate=maxtier1pp/equallevel
gen tier1elig=0
replace tier1elig=1 if assessmentpp<equallevel
gen undertier1maxamt=0
replace undertier1maxamt=1 if ((lerate/10000)-0.0035)<maxtier1rate
gen relassess=assessmentpp/equallevel
gen imptaxrate=.
replace imptaxrate=((lerate/10000)-0.0035)*invstenroll - (lerate/10000) + 0.0005 if undertier1max==1 & tier1elig==1
replace imptaxrate=-0.003 - maxtier1rate*(1-invstenroll*relassess) if undertier1max==0 & tier1elig==1
replace imptaxrate=-.003 if tier1elig==0 & year>1990
replace imptaxrate=0 if year<1991
sum imptaxrate if er==1 & year>1990 & year<1996 & undertier1maxamt==1
sum imptaxrate if tech==1 & year>1990 & year<1996 & undertier1maxamt==1
sum imptaxrate if tech==0 & er==0 & year>1990 & year<1996 & undertier1maxamt==1
sum imptaxrate if er==1 & year>1990 & year<1996 & undertier1maxamt==0
sum imptaxrate if tech==1 & year>1990 & year<1996 & undertier1maxamt==0
sum imptaxrate if tech==0 & er==0 & year>1990 & year<1996 & undertier1maxamt==0
sum imptaxrate if year>1990 & year<1996
sum maxtier1rate if year>1990 & year<1996

log close
